


***********************
**The Code below replicates the analysis from the State Context and Partisan Sorting dataset.
**use: "C: State Context and Partisan Sorting.dta"  or the appropriate file path on your computer.

**Structure

**The replication code generally follows the order of presentation in the main document, including the full estimates, conditional coefficients
**and figures. The full models reported in the supplemental materials are created within sections corresponding to figures presented in the main text.
**Tables are created with "outreg" and exported to Excel.  The Excel files can be found in the Stata working directory.  Tables where then 
**cleaned for presentation.  The code for graphs presented in the main body is included within each section.  Graphs were subsequently cleaned
**for presentation in Stata's Graph editor.

**Note that for a few figures presenting the change in PID or Partisan Sorting gaps, an additional dataset, "Context and Sorting Contrats.dta" was created from the conditional
**coefficients which were subsequently used to create the figure. Code to create the figures from Context and Sorting Contrasts.do is found in 
**Context and Sorting Contrasts.do is used to create the graphs and Stata graphics editor was then used to clean up the graph


***Log files, or related output export process, are highly recommended given the runtime of ~12 hours.

*set directory:    log using "C:\State Context and Sorting Log.smcl"






******PID Full Interactive Models

***Table A3 in Supplemental Materials --_Unstandardized Coefficients Table exported to Excel
mixed pid7_pt ib(1).race##c.ideo5_pt   ib(1).race##c.pct_black  ib(1).race##c.pct_latino ib(1).race##c.pct_asian_pi ib(1).race##c.pct_foreign_born ib(1).race##c.rate_black  ib(1).race##c.rate_latino ib(1).race##c.rate_asian ib(1).race##c.rate_foreign  ib(1).race##c.county_pct_black ib(1).race##c.county_pct_latino  ib(1).race##c.county_pct_asian_pi ib(1).race##c.county_pct_foreignborn ib(1).race##c.county_rate_black ib(1).race##c.county_rate_latino  ib(1).race##c.county_rate_asian ib(1).race##c.county_rate_foreignborn ib(1).race##c.hh_income_overall   ib(1).race##c.state_pop ib(1).race##c.density_pop ib(1).race##c.pct_college ib(1).race##c.unemployment ib(1).race##c.gini_coefficient ib(1).race##c.county_density  ib(1).race##c.county_pct_college ib(1).race##c.county_hh_income_overall ib(1).race##c.county_unemployment ib(1).race##c.county_gini_coefficient   ib(1).race##c.age ib(1).race##c.female ib(1).race##c.educ ib(1).race##c.protestant ib(1).race##c.catholic ib(1).race##c.evangelical ib(1).race##c.rel_attend ib(1).race##c.relig_import ib(1).race##c.parent ib(1).race##c.married ib(1).race##c.union_house ib(1).race##c.unemployed ib(1).race##c.r_hhinc ib(1).race##c.homeowner ib(1).race##c.newsint_recode  ib(1).race##c.south ib(1).race##i.year|| state:  || county_fips :  , var cov(id)
outreg2 using Table_1_PID.xls, ctitle(PID) label alpha(0.001, 0.01, 0.05)  dec(6)

***Table A--Conditional Coefficients for PID included in table A in the body of the paper
margins, dydx( ideo5_pt  pct_black    pct_latino  pct_asian_pi  pct_foreign_born  rate_black   rate_latino  rate_asian  rate_foreign   county_pct_black  county_pct_latino   county_pct_asian_pi  county_pct_foreignborn  county_rate_black  county_rate_latino   county_rate_asian  county_rate_foreignborn  hh_income_overall    state_pop  density_pop  pct_college  unemployment  gini_coefficient  county_density   county_pct_college  county_hh_income_overall  county_unemployment  county_gini_coefficient    age  female  educ  protestant  catholic  evangelical  rel_attend  relig_import  parent  married  union_house  unemployed  r_hhinc  homeowner  newsint_recode   south year) over(race) post
**margins are then cleaned-up for presentation in Excel and/or word


***Figure 1 Coefficient Plots by Race--altered with Stata Graph Editor to clean up the presentation
mixed pid7_pt ib(1).race##c.ideo5_pt   ib(1).race##c.pct_black  ib(1).race##c.pct_latino ib(1).race##c.pct_asian_pi ib(1).race##c.pct_foreign_born ib(1).race##c.rate_black  ib(1).race##c.rate_latino ib(1).race##c.rate_asian ib(1).race##c.rate_foreign  ib(1).race##c.county_pct_black ib(1).race##c.county_pct_latino  ib(1).race##c.county_pct_asian_pi ib(1).race##c.county_pct_foreignborn ib(1).race##c.county_rate_black ib(1).race##c.county_rate_latino  ib(1).race##c.county_rate_asian ib(1).race##c.county_rate_foreignborn ib(1).race##c.hh_income_overall   ib(1).race##c.state_pop ib(1).race##c.density_pop ib(1).race##c.pct_college ib(1).race##c.unemployment ib(1).race##c.gini_coefficient ib(1).race##c.county_density  ib(1).race##c.county_pct_college ib(1).race##c.county_hh_income_overall ib(1).race##c.county_unemployment ib(1).race##c.county_gini_coefficient   ib(1).race##c.age ib(1).race##c.female ib(1).race##c.educ ib(1).race##c.protestant ib(1).race##c.catholic ib(1).race##c.evangelical ib(1).race##c.rel_attend ib(1).race##c.relig_import ib(1).race##c.parent ib(1).race##c.married ib(1).race##c.union_house ib(1).race##c.unemployed ib(1).race##c.r_hhinc ib(1).race##c.homeowner ib(1).race##c.newsint_recode  ib(1).race##c.south ib(1).race##i.year|| state:  || county_fips :  , var cov(id)

margins, dydx(pct_black pct_latino pct_asian pct_foreign_born rate_black rate_latino rate_asian  rate_foreign ) over(race)
marginsplot, horizontal unique xline(0) ylabel(1 "Proportion Black" 2"Proportion Latino" 3"Proportion Asian/PI" 4"Proportion Foreign-Born" 5"Black Rate of Change" 6"Latino Rate of Change" 7"Asian/PI Rate of Change" 8"Foreign-Born Rate of Change") ytitle(State Racial/Ethnic Context) recast(scatter) yscale(reverse)  xtitle(Conditional Coefficients and 95% CIs for PID Model) title("") by(race)
graph save Figure_1.gph

*****FIgure 2 Contrasts and Contrast Graph for Change in PID Gap

***Contrasts are calculated and then entered into a new dataset.  Contrasts and CIs are reverse coded to add clarity to interpretation
**Reverse coding is needed since dif.(0) is subtracted from dif.(.2), resulting in a negative contrast if dif(.2) is larger.
mixed pid7_pt ib(1).race##c.ideo5_pt   ib(1).race##c.pct_black  ib(1).race##c.pct_latino ib(1).race##c.pct_asian_pi ib(1).race##c.pct_foreign_born ib(1).race##c.rate_black  ib(1).race##c.rate_latino ib(1).race##c.rate_asian ib(1).race##c.rate_foreign  ib(1).race##c.county_pct_black ib(1).race##c.county_pct_latino  ib(1).race##c.county_pct_asian_pi ib(1).race##c.county_pct_foreignborn ib(1).race##c.county_rate_black ib(1).race##c.county_rate_latino  ib(1).race##c.county_rate_asian ib(1).race##c.county_rate_foreignborn ib(1).race##c.hh_income_overall   ib(1).race##c.state_pop ib(1).race##c.density_pop ib(1).race##c.pct_college ib(1).race##c.unemployment ib(1).race##c.gini_coefficient ib(1).race##c.county_density  ib(1).race##c.county_pct_college ib(1).race##c.county_hh_income_overall ib(1).race##c.county_unemployment ib(1).race##c.county_gini_coefficient   ib(1).race##c.age ib(1).race##c.female ib(1).race##c.educ ib(1).race##c.protestant ib(1).race##c.catholic ib(1).race##c.evangelical ib(1).race##c.rel_attend ib(1).race##c.relig_import ib(1).race##c.parent ib(1).race##c.married ib(1).race##c.union_house ib(1).race##c.unemployed ib(1).race##c.r_hhinc ib(1).race##c.homeowner ib(1).race##c.newsint_recode  ib(1).race##c.south ib(1).race##i.year|| state:  || county_fips :  , var cov(id)



*Contrasts by Race
margins r.race, at(pct_black =(0 .20)) contrast(atcontrast(r))
margins r.race, at(pct_latino =(0 .20)) contrast(atcontrast(r))
margins r.race, at(pct_asian_pi =(0 .20)) contrast(atcontrast(r))
margins r.race, at(pct_foreign_born =(0 .10)) contrast(atcontrast(r))

******************************
*A new dataset of contrasts and CIs was created by copying results of the above margins commands. 
*For PID, contrasts were reverse coded to present more intuitive results given the default order of subtraction in Stata. 
*The Context and Sorting Contrasts.dta contains these results in a format that allows for creating the graph in Figure 2.
**use: Context and Sorting Contrats.dta
***Context and Sorting Contrasts.do is used to create the graphs and Stata graphics editor was then used to clean up the graph

***Stata graphics editor was then used to clean the graph for presentation.
*******************************


******Figure 3 Conditional Coefficients, Table A Conditional Coefficients, and Table A3 Partisan Sorting

***Table A3 in Supplemental Materials --_Unstandardized Coefficients Table exported to Excel
mixed part_sort_c ib(1).race##c.pct_black  ib(1).race##c.pct_latino ib(1).race##c.pct_asian_pi ib(1).race##c.pct_foreign_born ib(1).race##c.rate_black  ib(1).race##c.rate_latino ib(1).race##c.rate_asian ib(1).race##c.rate_foreign  ib(1).race##c.county_pct_black ib(1).race##c.county_pct_latino  ib(1).race##c.county_pct_asian_pi ib(1).race##c.county_pct_foreignborn ib(1).race##c.county_rate_black ib(1).race##c.county_rate_latino  ib(1).race##c.county_rate_asian ib(1).race##c.county_rate_foreignborn ib(1).race##c.hh_income_overall   ib(1).race##c.state_pop ib(1).race##c.density_pop ib(1).race##c.pct_college ib(1).race##c.unemployment ib(1).race##c.gini_coefficient ib(1).race##c.county_density  ib(1).race##c.county_pct_college ib(1).race##c.county_hh_income_overall ib(1).race##c.county_unemployment ib(1).race##c.county_gini_coefficient   ib(1).race##c.age ib(1).race##c.female ib(1).race##c.educ ib(1).race##c.protestant ib(1).race##c.catholic ib(1).race##c.evangelical ib(1).race##c.rel_attend ib(1).race##c.relig_import ib(1).race##c.parent ib(1).race##c.married ib(1).race##c.union_house ib(1).race##c.unemployed ib(1).race##c.r_hhinc ib(1).race##c.homeowner ib(1).race##c.newsint_recode  ib(1).race##c.south ib(1).race##i.year|| state:  || county_fips :  , var cov(id)
outreg2 using Table_2_Part_Sort.xls, ctitle(Part Sort) label alpha(0.001, 0.01, 0.05)  dec(6)

***Table A--Conditional Coefficients for Partisan Ideological Sorting included in table A in the body of the paper
margins, dydx(   pct_black    pct_latino  pct_asian_pi  pct_foreign_born  rate_black   rate_latino  rate_asian  rate_foreign   county_pct_black  county_pct_latino   county_pct_asian_pi  county_pct_foreignborn  county_rate_black  county_rate_latino   county_rate_asian  county_rate_foreignborn  hh_income_overall    state_pop  density_pop  pct_college  unemployment  gini_coefficient  county_density   county_pct_college  county_hh_income_overall  county_unemployment  county_gini_coefficient    age  female  educ  protestant  catholic  evangelical  rel_attend  relig_import  parent  married  union_house  unemployed  r_hhinc  homeowner  newsint_recode   south year) over(race) post
**margins are then cleaned-up for presentation in Excel and/or word


***Figure 3 Coefficient Plots by Race--altered with Stata Graph Editor to clean up the presentation
mixed part_sort_c   ib(1).race##c.pct_black  ib(1).race##c.pct_latino ib(1).race##c.pct_asian_pi ib(1).race##c.pct_foreign_born ib(1).race##c.rate_black  ib(1).race##c.rate_latino ib(1).race##c.rate_asian ib(1).race##c.rate_foreign  ib(1).race##c.county_pct_black ib(1).race##c.county_pct_latino  ib(1).race##c.county_pct_asian_pi ib(1).race##c.county_pct_foreignborn ib(1).race##c.county_rate_black ib(1).race##c.county_rate_latino  ib(1).race##c.county_rate_asian ib(1).race##c.county_rate_foreignborn ib(1).race##c.hh_income_overall   ib(1).race##c.state_pop ib(1).race##c.density_pop ib(1).race##c.pct_college ib(1).race##c.unemployment ib(1).race##c.gini_coefficient ib(1).race##c.county_density  ib(1).race##c.county_pct_college ib(1).race##c.county_hh_income_overall ib(1).race##c.county_unemployment ib(1).race##c.county_gini_coefficient   ib(1).race##c.age ib(1).race##c.female ib(1).race##c.educ ib(1).race##c.protestant ib(1).race##c.catholic ib(1).race##c.evangelical ib(1).race##c.rel_attend ib(1).race##c.relig_import ib(1).race##c.parent ib(1).race##c.married ib(1).race##c.union_house ib(1).race##c.unemployed ib(1).race##c.r_hhinc ib(1).race##c.homeowner ib(1).race##c.newsint_recode  ib(1).race##c.south ib(1).race##i.year|| state:  || county_fips :  , var cov(id)

margins, dydx(pct_black pct_latino pct_asian pct_foreign_born rate_black rate_latino rate_asian  rate_foreign ) over(race)
marginsplot, horizontal unique xline(0) ylabel(1 "Proportion Black" 2"Proportion Latino" 3"Proportion Asian/PI" 4"Proportion Foreign-Born" 5"Black Rate of Change" 6"Latino Rate of Change" 7"Asian/PI Rate of Change" 8"Foreign-Born Rate of Change") ytitle(State Racial/Ethnic Context) recast(scatter) yscale(reverse)  xtitle(Conditional Coefficients and 95% CIs for Partisan Sorting Model) title("") by(race)
graph save Figure_3.gph



*****Figure 4 Conditional Coefficients for Partisan Sorting by Race and Party
**Four separate models for each racial/ethnic group
**Marginsplots are then edited lightly in State Graphing Editor

**White Partisan Sorting by Party (Figure 4a)

mixed part_sort_c  i.Republican##c.pct_black  i.Republican##c.pct_latino i.Republican##c.pct_asian_pi i.Republican##c.pct_foreign_born i.Republican##c.rate_black  i.Republican##c.rate_latino i.Republican##c.rate_asian i.Republican##c.rate_foreign  i.Republican##c.county_pct_black i.Republican##c.county_pct_latino  i.Republican##c.county_pct_asian_pi i.Republican##c.county_pct_foreignborn i.Republican##c.county_rate_black i.Republican##c.county_rate_latino  i.Republican##c.county_rate_asian i.Republican##c.county_rate_foreignborn i.Republican##c.hh_income_overall   i.Republican##c.state_pop i.Republican##c.density_pop i.Republican##c.pct_college i.Republican##c.unemployment i.Republican##c.gini_coefficient i.Republican##c.county_density  i.Republican##c.county_pct_college i.Republican##c.county_hh_income_overall i.Republican##c.county_unemployment i.Republican##c.county_gini_coefficient   i.Republican##c.age i.Republican##c.female i.Republican##c.educ i.Republican##c.protestant i.Republican##c.catholic i.Republican##c.evangelical i.Republican##c.rel_attend i.Republican##c.relig_import i.Republican##parent i.Republican##c.married i.Republican##c.union_house i.Republican##c.unemployed i.Republican##c.r_hhinc i.Republican##c.newsint_recode i.Republican##c.south i.Republican##i.year if race==1  || state:  || county_fips :  , var cov(id)

margins, dydx(pct_black pct_latino pct_asian pct_foreign_born rate_black rate_latino rate_asian  rate_foreign ) over(Republican)
marginsplot, horizontal unique xline(0) ylabel(1 "Proportion Black" 2"Proportion Latino" 3"Proportion Asian/PI" 4"Proportion Foreign-Born" 5"Black Rate of Change" 6"Latino Rate of Change" 7"Asian/PI Rate of Change" 8"Foreign-Born Rate of Change") ytitle(State Racial/Ethnic Context) recast(scatter) yscale(reverse)  xtitle(Conditional Coefficients and 95% CIs for Partisan Sorting Model) title("") by(Republican)
graph save Figure_4a.gph


**Black Partisan Sorting by Party (Figure 4b)

mixed part_sort_c  i.Republican##c.pct_black  i.Republican##c.pct_latino i.Republican##c.pct_asian_pi i.Republican##c.pct_foreign_born i.Republican##c.rate_black  i.Republican##c.rate_latino i.Republican##c.rate_asian i.Republican##c.rate_foreign  i.Republican##c.county_pct_black i.Republican##c.county_pct_latino  i.Republican##c.county_pct_asian_pi i.Republican##c.county_pct_foreignborn i.Republican##c.county_rate_black i.Republican##c.county_rate_latino  i.Republican##c.county_rate_asian i.Republican##c.county_rate_foreignborn i.Republican##c.hh_income_overall   i.Republican##c.state_pop i.Republican##c.density_pop i.Republican##c.pct_college i.Republican##c.unemployment i.Republican##c.gini_coefficient i.Republican##c.county_density  i.Republican##c.county_pct_college i.Republican##c.county_hh_income_overall i.Republican##c.county_unemployment i.Republican##c.county_gini_coefficient   i.Republican##c.age i.Republican##c.female i.Republican##c.educ i.Republican##c.protestant i.Republican##c.catholic i.Republican##c.evangelical i.Republican##c.rel_attend i.Republican##c.relig_import i.Republican##parent i.Republican##c.married i.Republican##c.union_house i.Republican##c.unemployed i.Republican##c.r_hhinc i.Republican##c.newsint_recode i.Republican##c.south i.Republican##i.year if race==2|| state:  || county_fips :  , var cov(id)

margins, dydx(pct_black pct_latino pct_asian pct_foreign_born rate_black rate_latino rate_asian  rate_foreign ) over(Republican)
marginsplot, horizontal unique xline(0) ylabel(1 "Proportion Black" 2"Proportion Latino" 3"Proportion Asian/PI" 4"Proportion Foreign-Born" 5"Black Rate of Change" 6"Latino Rate of Change" 7"Asian/PI Rate of Change" 8"Foreign-Born Rate of Change") ytitle(State Racial/Ethnic Context) recast(scatter) yscale(reverse)  xtitle(Conditional Coefficients and 95% CIs for Partisan Sorting Model) title("") by(Republican)
graph save Figure_4b.gph

**Latino Partisan Sorting by Party (Figure 4c)

mixed part_sort_c  i.Republican##c.pct_black  i.Republican##c.pct_latino i.Republican##c.pct_asian_pi i.Republican##c.pct_foreign_born i.Republican##c.rate_black  i.Republican##c.rate_latino i.Republican##c.rate_asian i.Republican##c.rate_foreign  i.Republican##c.county_pct_black i.Republican##c.county_pct_latino  i.Republican##c.county_pct_asian_pi i.Republican##c.county_pct_foreignborn i.Republican##c.county_rate_black i.Republican##c.county_rate_latino  i.Republican##c.county_rate_asian i.Republican##c.county_rate_foreignborn i.Republican##c.hh_income_overall   i.Republican##c.state_pop i.Republican##c.density_pop i.Republican##c.pct_college i.Republican##c.unemployment i.Republican##c.gini_coefficient i.Republican##c.county_density  i.Republican##c.county_pct_college i.Republican##c.county_hh_income_overall i.Republican##c.county_unemployment i.Republican##c.county_gini_coefficient   i.Republican##c.age i.Republican##c.female i.Republican##c.educ i.Republican##c.protestant i.Republican##c.catholic i.Republican##c.evangelical i.Republican##c.rel_attend i.Republican##c.relig_import i.Republican##parent i.Republican##c.married i.Republican##c.union_house i.Republican##c.unemployed i.Republican##c.r_hhinc i.Republican##c.newsint_recode i.Republican##c.south i.Republican##i.year if race==3|| state:  || county_fips :  , var cov(id)

margins, dydx(pct_black pct_latino pct_asian pct_foreign_born rate_black rate_latino rate_asian  rate_foreign ) over(Republican)
marginsplot, horizontal unique xline(0) ylabel(1 "Proportion Black" 2"Proportion Latino" 3"Proportion Asian/PI" 4"Proportion Foreign-Born" 5"Black Rate of Change" 6"Latino Rate of Change" 7"Asian/PI Rate of Change" 8"Foreign-Born Rate of Change") ytitle(State Racial/Ethnic Context) recast(scatter) yscale(reverse)  xtitle(Conditional Coefficients and 95% CIs for Partisan Sorting Model) title("") by(Republican)
graph save Figure_4c.gph


***Asian/PI Partisan Sorting by Party (Figure 4d)

mixed part_sort_c  i.Republican##c.pct_black  i.Republican##c.pct_latino i.Republican##c.pct_asian_pi i.Republican##c.pct_foreign_born i.Republican##c.rate_black  i.Republican##c.rate_latino i.Republican##c.rate_asian i.Republican##c.rate_foreign  i.Republican##c.county_pct_black i.Republican##c.county_pct_latino  i.Republican##c.county_pct_asian_pi i.Republican##c.county_pct_foreignborn i.Republican##c.county_rate_black i.Republican##c.county_rate_latino  i.Republican##c.county_rate_asian i.Republican##c.county_rate_foreignborn i.Republican##c.hh_income_overall   i.Republican##c.state_pop i.Republican##c.density_pop i.Republican##c.pct_college i.Republican##c.unemployment i.Republican##c.gini_coefficient i.Republican##c.county_density  i.Republican##c.county_pct_college i.Republican##c.county_hh_income_overall i.Republican##c.county_unemployment i.Republican##c.county_gini_coefficient   i.Republican##c.age i.Republican##c.female i.Republican##c.educ i.Republican##c.protestant i.Republican##c.catholic i.Republican##c.evangelical i.Republican##c.rel_attend i.Republican##c.relig_import i.Republican##parent i.Republican##c.married i.Republican##c.union_house i.Republican##c.unemployed i.Republican##c.r_hhinc i.Republican##c.newsint_recode i.Republican##c.south i.Republican##i.year if race==4|| state:  || county_fips :  , var cov(id)

margins, dydx(pct_black pct_latino pct_asian pct_foreign_born rate_black rate_latino rate_asian  rate_foreign ) over(Republican)
marginsplot, horizontal unique xline(0) ylabel(1 "Proportion Black" 2"Proportion Latino" 3"Proportion Asian/PI" 4"Proportion Foreign-Born" 5"Black Rate of Change" 6"Latino Rate of Change" 7"Asian/PI Rate of Change" 8"Foreign-Born Rate of Change") ytitle(State Racial/Ethnic Context) recast(scatter) yscale(reverse)  xtitle(Conditional Coefficients and 95% CIs for Partisan Sorting Model) title("") by(Republican), 

graph save Figure_4d.gph


*********Figure 5   Change in Partisan Sorting Across Racial/Ethnic Contexts

***Partisan Sorting Model Interaction with Republicans (Full Sample)
mixed part_sort_c  i.Republican##c.pct_black  i.Republican##c.pct_latino i.Republican##c.pct_asian_pi i.Republican##c.pct_foreign_born i.Republican##c.rate_black  i.Republican##c.rate_latino i.Republican##c.rate_asian i.Republican##c.rate_foreign  i.Republican##c.county_pct_black i.Republican##c.county_pct_latino  i.Republican##c.county_pct_asian_pi i.Republican##c.county_pct_foreignborn i.Republican##c.county_rate_black i.Republican##c.county_rate_latino  i.Republican##c.county_rate_asian i.Republican##c.county_rate_foreignborn i.Republican##c.hh_income_overall   i.Republican##c.state_pop i.Republican##c.density_pop i.Republican##c.pct_college i.Republican##c.unemployment i.Republican##c.gini_coefficient i.Republican##c.county_density  i.Republican##c.county_pct_college i.Republican##c.county_hh_income_overall i.Republican##c.county_unemployment i.Republican##c.county_gini_coefficient   i.Republican##c.age i.Republican##c.female i.Republican##c.educ i.Republican##c.protestant i.Republican##c.catholic i.Republican##c.evangelical i.Republican##c.rel_attend i.Republican##c.relig_import i.Republican##parent i.Republican##c.married i.Republican##c.union_house i.Republican##c.unemployed i.Republican##c.r_hhinc i.Republican##c.newsint_recode i.Republican##c.south i.Republican##i.year|| state:  || county_fips :  , var cov(id)


**Contrasts for full sample
**Contrast Results are then added to a new dataset to create graph

*Contrasts Graphs
margins r.Republican, at(pct_black =(0 .20)) contrast(atcontrast(r))
margins r.Republican, at(pct_latino =(0 .20)) contrast(atcontrast(r))
margins r.Republican, at(pct_asian_pi =(0 .20)) contrast(atcontrast(r))
margins r.Republican, at(pct_foreign_born =(0 .10)) contrast(atcontrast(r))


***Partisan Sorting Model Interaction with Republicans (White Sample)
mixed part_sort_c  i.Republican##c.pct_black  i.Republican##c.pct_latino i.Republican##c.pct_asian_pi i.Republican##c.pct_foreign_born i.Republican##c.rate_black  i.Republican##c.rate_latino i.Republican##c.rate_asian i.Republican##c.rate_foreign  i.Republican##c.county_pct_black i.Republican##c.county_pct_latino  i.Republican##c.county_pct_asian_pi i.Republican##c.county_pct_foreignborn i.Republican##c.county_rate_black i.Republican##c.county_rate_latino  i.Republican##c.county_rate_asian i.Republican##c.county_rate_foreignborn i.Republican##c.hh_income_overall   i.Republican##c.state_pop i.Republican##c.density_pop i.Republican##c.pct_college i.Republican##c.unemployment i.Republican##c.gini_coefficient i.Republican##c.county_density  i.Republican##c.county_pct_college i.Republican##c.county_hh_income_overall i.Republican##c.county_unemployment i.Republican##c.county_gini_coefficient   i.Republican##c.age i.Republican##c.female i.Republican##c.educ i.Republican##c.protestant i.Republican##c.catholic i.Republican##c.evangelical i.Republican##c.rel_attend i.Republican##c.relig_import i.Republican##parent i.Republican##c.married i.Republican##c.union_house i.Republican##c.unemployed i.Republican##c.r_hhinc i.Republican##c.newsint_recode i.Republican##c.south i.Republican##i.year if race==1|| state:  || county_fips :  , var cov(id)

**Contrasts for White Sample
**Contrast Results are then added to a new dataset to create graph

*Contrasts Graphs
margins r.Republican, at(pct_black =(0 .20)) contrast(atcontrast(r))
margins r.Republican, at(pct_latino =(0 .20)) contrast(atcontrast(r))
margins r.Republican, at(pct_asian_pi =(0 .20)) contrast(atcontrast(r))
margins r.Republican, at(pct_foreign_born =(0 .10)) contrast(atcontrast(r))

*****************************************
*****Results from the above were added to the "Context and Sorting Contrasts.dta" file with contrasts, CIs and labels as noted above.  Default contrasts were employed here.

***Context and Sorting Contrasts.do is used to create the graphs and Stata graphics editor was then used to clean up the graph




********Alternative Partisan Sorting included in Table A3
**Output created in Excel file and then cleaned for presentation in Word

**Mason Partisan Sorting for Table A3 in Supplemental Materials --_Unstandardized Coefficients Table exported to Excel
mixed part_sort ib(1).race##c.pct_black  ib(1).race##c.pct_latino ib(1).race##c.pct_asian_pi ib(1).race##c.pct_foreign_born ib(1).race##c.rate_black  ib(1).race##c.rate_latino ib(1).race##c.rate_asian ib(1).race##c.rate_foreign  ib(1).race##c.county_pct_black ib(1).race##c.county_pct_latino  ib(1).race##c.county_pct_asian_pi ib(1).race##c.county_pct_foreignborn ib(1).race##c.county_rate_black ib(1).race##c.county_rate_latino  ib(1).race##c.county_rate_asian ib(1).race##c.county_rate_foreignborn ib(1).race##c.hh_income_overall   ib(1).race##c.state_pop ib(1).race##c.density_pop ib(1).race##c.pct_college ib(1).race##c.unemployment ib(1).race##c.gini_coefficient ib(1).race##c.county_density  ib(1).race##c.county_pct_college ib(1).race##c.county_hh_income_overall ib(1).race##c.county_unemployment ib(1).race##c.county_gini_coefficient   ib(1).race##c.age ib(1).race##c.female ib(1).race##c.educ ib(1).race##c.protestant ib(1).race##c.catholic ib(1).race##c.evangelical ib(1).race##c.rel_attend ib(1).race##c.relig_import ib(1).race##c.parent ib(1).race##c.married ib(1).race##c.union_house ib(1).race##c.unemployed ib(1).race##c.r_hhinc ib(1).race##c.homeowner ib(1).race##c.newsint_recode  ib(1).race##c.south ib(1).race##i.year|| state:  || county_fips :  , var cov(id)
outreg2 using Table_2_Part_Sort.xls, ctitle(Mason Part Sort) label alpha(0.001, 0.01, 0.05)  dec(6)


**Alternative Partisan Sorting Table A3 in Supplemental Materials --_Unstandardized Coefficients Table exported to Excel
mixed part_sort_a ib(1).race##c.pct_black  ib(1).race##c.pct_latino ib(1).race##c.pct_asian_pi ib(1).race##c.pct_foreign_born ib(1).race##c.rate_black  ib(1).race##c.rate_latino ib(1).race##c.rate_asian ib(1).race##c.rate_foreign  ib(1).race##c.county_pct_black ib(1).race##c.county_pct_latino  ib(1).race##c.county_pct_asian_pi ib(1).race##c.county_pct_foreignborn ib(1).race##c.county_rate_black ib(1).race##c.county_rate_latino  ib(1).race##c.county_rate_asian ib(1).race##c.county_rate_foreignborn ib(1).race##c.hh_income_overall   ib(1).race##c.state_pop ib(1).race##c.density_pop ib(1).race##c.pct_college ib(1).race##c.unemployment ib(1).race##c.gini_coefficient ib(1).race##c.county_density  ib(1).race##c.county_pct_college ib(1).race##c.county_hh_income_overall ib(1).race##c.county_unemployment ib(1).race##c.county_gini_coefficient   ib(1).race##c.age ib(1).race##c.female ib(1).race##c.educ ib(1).race##c.protestant ib(1).race##c.catholic ib(1).race##c.evangelical ib(1).race##c.rel_attend ib(1).race##c.relig_import ib(1).race##c.parent ib(1).race##c.married ib(1).race##c.union_house ib(1).race##c.unemployed ib(1).race##c.r_hhinc ib(1).race##c.homeowner ib(1).race##c.newsint_recode  ib(1).race##c.south ib(1).race##i.year|| state:  || county_fips :  , var cov(id)
outreg2 using Table_2_Part_Sort.xls, ctitle(Alternative Partisan Sorting) label alpha(0.001, 0.01, 0.05)  dec(6)


********Figure A1 Conditional Coefficients for Partisan Ideological Sorting for Non-Southern Whites
mixed part_sort_c ib(1).south##c.pct_black  ib(1).south##c.pct_latino ib(1).south##c.pct_asian_pi ib(1).south##c.pct_foreign_born ib(1).south##c.rate_black  ib(1).south##c.rate_latino ib(1).south##c.rate_asian ib(1).south##c.rate_foreign  ib(1).south##c.county_pct_black ib(1).south##c.county_pct_latino  ib(1).south##c.county_pct_asian_pi ib(1).south##c.county_pct_foreignborn ib(1).south##c.county_rate_black ib(1).south##c.county_rate_latino  ib(1).south##c.county_rate_asian ib(1).south##c.county_rate_foreignborn ib(1).south##c.hh_income_overall   ib(1).south##c.state_pop ib(1).south##c.density_pop ib(1).south##c.pct_college ib(1).south##c.unemployment ib(1).south##c.gini_coefficient ib(1).south##c.county_density  ib(1).south##c.county_pct_college ib(1).south##c.county_hh_income_overall ib(1).south##c.county_unemployment ib(1).south##c.county_gini_coefficient   ib(1).south##c.age ib(1).south##c.female ib(1).south##c.educ ib(1).south##c.protestant ib(1).south##c.catholic ib(1).south##c.evangelical ib(1).south##c.rel_attend ib(1).south##c.relig_import ib(1).south##c.parent ib(1).south##c.married ib(1).south##c.union_house ib(1).south##c.unemployed ib(1).south##c.r_hhinc ib(1).south##c.homeowner ib(1).south##c.newsint_recode  ib(1).south##i.year if race==1 || state:  || county_fips :  , var cov(id)
margins if south==0, dydx(pct_black pct_latino pct_asian pct_foreign_born rate_black rate_latino rate_asian  rate_foreign )

marginsplot, horizontal unique xline(0) ylabel(1 "Proportion Black" 2"Proportion Latino" 3"Proportion Asian/PI" 4"Proportion Foreign-Born" 5"Black Rate of Change" 6"Latino Rate of Change" 7"Asian/PI Rate of Change" 8"Foreign-Born Rate of Change") ytitle(State Racial/Ethnic Context) recast(scatter) yscale(reverse)  xtitle(Conditional Coefficients and 95% CIs for Partisan Sorting Model) title("")


********Table A4 Conditional Coefficients for Sorting by Party

***Democrats
mixed part_sort_c ib(1).race##c.pct_black  ib(1).race##c.pct_latino ib(1).race##c.pct_asian_pi ib(1).race##c.pct_foreign_born ib(1).race##c.rate_black  ib(1).race##c.rate_latino ib(1).race##c.rate_asian ib(1).race##c.rate_foreign  ib(1).race##c.county_pct_black ib(1).race##c.county_pct_latino  ib(1).race##c.county_pct_asian_pi ib(1).race##c.county_pct_foreignborn ib(1).race##c.county_rate_black ib(1).race##c.county_rate_latino  ib(1).race##c.county_rate_asian ib(1).race##c.county_rate_foreignborn ib(1).race##c.hh_income_overall   ib(1).race##c.state_pop ib(1).race##c.density_pop ib(1).race##c.pct_college ib(1).race##c.unemployment ib(1).race##c.gini_coefficient ib(1).race##c.county_density  ib(1).race##c.county_pct_college ib(1).race##c.county_hh_income_overall ib(1).race##c.county_unemployment ib(1).race##c.county_gini_coefficient   ib(1).race##c.age ib(1).race##c.female ib(1).race##c.educ ib(1).race##c.protestant ib(1).race##c.catholic ib(1).race##c.evangelical ib(1).race##c.rel_attend ib(1).race##c.relig_import ib(1).race##c.parent ib(1).race##c.married ib(1).race##c.union_house ib(1).race##c.unemployed ib(1).race##c.r_hhinc ib(1).race##c.homeowner ib(1).race##c.newsint_recode  ib(1).race##c.south ib(1).race##i.year if pid7_pt<4|| state:  || county_fips :  , var cov(id)
margins, dydx(   pct_black    pct_latino  pct_asian_pi  pct_foreign_born  rate_black   rate_latino  rate_asian  rate_foreign   county_pct_black  county_pct_latino   county_pct_asian_pi  county_pct_foreignborn  county_rate_black  county_rate_latino   county_rate_asian  county_rate_foreignborn  hh_income_overall    state_pop  density_pop  pct_college  unemployment  gini_coefficient  county_density   county_pct_college  county_hh_income_overall  county_unemployment  county_gini_coefficient    age  female  educ  protestant  catholic  evangelical  rel_attend  relig_import  parent  married  union_house  unemployed  r_hhinc  homeowner  newsint_recode   south year) over(race) post
***Republicans
mixed part_sort_c ib(1).race##c.pct_black  ib(1).race##c.pct_latino ib(1).race##c.pct_asian_pi ib(1).race##c.pct_foreign_born ib(1).race##c.rate_black  ib(1).race##c.rate_latino ib(1).race##c.rate_asian ib(1).race##c.rate_foreign  ib(1).race##c.county_pct_black ib(1).race##c.county_pct_latino  ib(1).race##c.county_pct_asian_pi ib(1).race##c.county_pct_foreignborn ib(1).race##c.county_rate_black ib(1).race##c.county_rate_latino  ib(1).race##c.county_rate_asian ib(1).race##c.county_rate_foreignborn ib(1).race##c.hh_income_overall   ib(1).race##c.state_pop ib(1).race##c.density_pop ib(1).race##c.pct_college ib(1).race##c.unemployment ib(1).race##c.gini_coefficient ib(1).race##c.county_density  ib(1).race##c.county_pct_college ib(1).race##c.county_hh_income_overall ib(1).race##c.county_unemployment ib(1).race##c.county_gini_coefficient   ib(1).race##c.age ib(1).race##c.female ib(1).race##c.educ ib(1).race##c.protestant ib(1).race##c.catholic ib(1).race##c.evangelical ib(1).race##c.rel_attend ib(1).race##c.relig_import ib(1).race##c.parent ib(1).race##c.married ib(1).race##c.union_house ib(1).race##c.unemployed ib(1).race##c.r_hhinc ib(1).race##c.homeowner ib(1).race##c.newsint_recode  ib(1).race##c.south ib(1).race##i.year if pid7_pt>4|| state:  || county_fips :  , var cov(id)
margins, dydx( pct_black    pct_latino  pct_asian_pi  pct_foreign_born  rate_black   rate_latino  rate_asian  rate_foreign   county_pct_black  county_pct_latino   county_pct_asian_pi  county_pct_foreignborn  county_rate_black  county_rate_latino   county_rate_asian  county_rate_foreignborn  hh_income_overall    state_pop  density_pop  pct_college  unemployment  gini_coefficient  county_density   county_pct_college  county_hh_income_overall  county_unemployment  county_gini_coefficient    age  female  educ  protestant  catholic  evangelical  rel_attend  relig_import  parent  married  union_house  unemployed  r_hhinc  homeowner  newsint_recode   south year) over(race) post

***Margins were cleaned-up for presentation in Excel and Word



*******Table A5 Full Interactive PID excluding CA, FL and HI Unconditional Coefficients


**Excluding CA
mixed pid7_pt ib(1).race##c.ideo5_pt   ib(1).race##c.pct_black  ib(1).race##c.pct_latino ib(1).race##c.pct_asian_pi ib(1).race##c.pct_foreign_born ib(1).race##c.rate_black  ib(1).race##c.rate_latino ib(1).race##c.rate_asian ib(1).race##c.rate_foreign  ib(1).race##c.county_pct_black ib(1).race##c.county_pct_latino  ib(1).race##c.county_pct_asian_pi ib(1).race##c.county_pct_foreignborn ib(1).race##c.county_rate_black ib(1).race##c.county_rate_latino  ib(1).race##c.county_rate_asian ib(1).race##c.county_rate_foreignborn ib(1).race##c.hh_income_overall   ib(1).race##c.state_pop ib(1).race##c.density_pop ib(1).race##c.pct_college ib(1).race##c.unemployment ib(1).race##c.gini_coefficient ib(1).race##c.county_density  ib(1).race##c.county_pct_college ib(1).race##c.county_hh_income_overall ib(1).race##c.county_unemployment ib(1).race##c.county_gini_coefficient   ib(1).race##c.age ib(1).race##c.female ib(1).race##c.educ ib(1).race##c.protestant ib(1).race##c.catholic ib(1).race##c.evangelical ib(1).race##c.rel_attend ib(1).race##c.relig_import ib(1).race##c.parent ib(1).race##c.married ib(1).race##c.union_house ib(1).race##c.unemployed ib(1).race##c.r_hhinc ib(1).race##c.homeowner ib(1).race##c.newsint_recode  ib(1).race##c.south ib(1).race##i.year if state~=6 || state:  || county_fips :  , var cov(id)
outreg2 using Table_5_PID_robust.xls, ctitle(PID Excluding CA) label alpha(0.001, 0.01, 0.05)  dec(6)

**Excluding FL
mixed pid7_pt ib(1).race##c.ideo5_pt   ib(1).race##c.pct_black  ib(1).race##c.pct_latino ib(1).race##c.pct_asian_pi ib(1).race##c.pct_foreign_born ib(1).race##c.rate_black  ib(1).race##c.rate_latino ib(1).race##c.rate_asian ib(1).race##c.rate_foreign  ib(1).race##c.county_pct_black ib(1).race##c.county_pct_latino  ib(1).race##c.county_pct_asian_pi ib(1).race##c.county_pct_foreignborn ib(1).race##c.county_rate_black ib(1).race##c.county_rate_latino  ib(1).race##c.county_rate_asian ib(1).race##c.county_rate_foreignborn ib(1).race##c.hh_income_overall   ib(1).race##c.state_pop ib(1).race##c.density_pop ib(1).race##c.pct_college ib(1).race##c.unemployment ib(1).race##c.gini_coefficient ib(1).race##c.county_density  ib(1).race##c.county_pct_college ib(1).race##c.county_hh_income_overall ib(1).race##c.county_unemployment ib(1).race##c.county_gini_coefficient   ib(1).race##c.age ib(1).race##c.female ib(1).race##c.educ ib(1).race##c.protestant ib(1).race##c.catholic ib(1).race##c.evangelical ib(1).race##c.rel_attend ib(1).race##c.relig_import ib(1).race##c.parent ib(1).race##c.married ib(1).race##c.union_house ib(1).race##c.unemployed ib(1).race##c.r_hhinc ib(1).race##c.homeowner ib(1).race##c.newsint_recode  ib(1).race##c.south ib(1).race##i.year if state~=12|| state:  || county_fips :  , var cov(id)
outreg2 using Table_5_PID_robust.xls, ctitle(PID Excluding FL) label alpha(0.001, 0.01, 0.05)  dec(6)

**Excluding HI
mixed pid7_pt ib(1).race##c.ideo5_pt   ib(1).race##c.pct_black  ib(1).race##c.pct_latino ib(1).race##c.pct_asian_pi ib(1).race##c.pct_foreign_born ib(1).race##c.rate_black  ib(1).race##c.rate_latino ib(1).race##c.rate_asian ib(1).race##c.rate_foreign  ib(1).race##c.county_pct_black ib(1).race##c.county_pct_latino  ib(1).race##c.county_pct_asian_pi ib(1).race##c.county_pct_foreignborn ib(1).race##c.county_rate_black ib(1).race##c.county_rate_latino  ib(1).race##c.county_rate_asian ib(1).race##c.county_rate_foreignborn ib(1).race##c.hh_income_overall   ib(1).race##c.state_pop ib(1).race##c.density_pop ib(1).race##c.pct_college ib(1).race##c.unemployment ib(1).race##c.gini_coefficient ib(1).race##c.county_density  ib(1).race##c.county_pct_college ib(1).race##c.county_hh_income_overall ib(1).race##c.county_unemployment ib(1).race##c.county_gini_coefficient   ib(1).race##c.age ib(1).race##c.female ib(1).race##c.educ ib(1).race##c.protestant ib(1).race##c.catholic ib(1).race##c.evangelical ib(1).race##c.rel_attend ib(1).race##c.relig_import ib(1).race##c.parent ib(1).race##c.married ib(1).race##c.union_house ib(1).race##c.unemployed ib(1).race##c.r_hhinc ib(1).race##c.homeowner ib(1).race##c.newsint_recode  ib(1).race##c.south ib(1).race##i.year if state~=15|| state:  || county_fips :  , var cov(id)
outreg2 using Table_5_PID_robust.xls, ctitle(PID Excluding HI) label alpha(0.001, 0.01, 0.05)  dec(6)

**********Table A6 Democratic Respondent Full Model of Partisan Ideological Sorting without CA, FL and HI

**Excluding CA

mixed part_sort_c ib(1).race##c.pct_black  ib(1).race##c.pct_latino ib(1).race##c.pct_asian_pi ib(1).race##c.pct_foreign_born ib(1).race##c.rate_black  ib(1).race##c.rate_latino ib(1).race##c.rate_asian ib(1).race##c.rate_foreign  ib(1).race##c.county_pct_black ib(1).race##c.county_pct_latino  ib(1).race##c.county_pct_asian_pi ib(1).race##c.county_pct_foreignborn ib(1).race##c.county_rate_black ib(1).race##c.county_rate_latino  ib(1).race##c.county_rate_asian ib(1).race##c.county_rate_foreignborn ib(1).race##c.hh_income_overall   ib(1).race##c.state_pop ib(1).race##c.density_pop ib(1).race##c.pct_college ib(1).race##c.unemployment ib(1).race##c.gini_coefficient ib(1).race##c.county_density  ib(1).race##c.county_pct_college ib(1).race##c.county_hh_income_overall ib(1).race##c.county_unemployment ib(1).race##c.county_gini_coefficient   ib(1).race##c.age ib(1).race##c.female ib(1).race##c.educ ib(1).race##c.protestant ib(1).race##c.catholic ib(1).race##c.evangelical ib(1).race##c.rel_attend ib(1).race##c.relig_import ib(1).race##c.parent ib(1).race##c.married ib(1).race##c.union_house ib(1).race##c.unemployed ib(1).race##c.r_hhinc ib(1).race##c.homeowner ib(1).race##c.newsint_recode  ib(1).race##c.south ib(1).race##i.year if pid7_pt<4& state~=6|| state:  || county_fips :  , var cov(id)
outreg2 using Table_2_Part_Sort.xls, ctitle(Dem NO CA) label alpha(0.001, 0.01, 0.05)  dec(6)

**Excluding FL
mixed part_sort_c ib(1).race##c.pct_black  ib(1).race##c.pct_latino ib(1).race##c.pct_asian_pi ib(1).race##c.pct_foreign_born ib(1).race##c.rate_black  ib(1).race##c.rate_latino ib(1).race##c.rate_asian ib(1).race##c.rate_foreign  ib(1).race##c.county_pct_black ib(1).race##c.county_pct_latino  ib(1).race##c.county_pct_asian_pi ib(1).race##c.county_pct_foreignborn ib(1).race##c.county_rate_black ib(1).race##c.county_rate_latino  ib(1).race##c.county_rate_asian ib(1).race##c.county_rate_foreignborn ib(1).race##c.hh_income_overall   ib(1).race##c.state_pop ib(1).race##c.density_pop ib(1).race##c.pct_college ib(1).race##c.unemployment ib(1).race##c.gini_coefficient ib(1).race##c.county_density  ib(1).race##c.county_pct_college ib(1).race##c.county_hh_income_overall ib(1).race##c.county_unemployment ib(1).race##c.county_gini_coefficient   ib(1).race##c.age ib(1).race##c.female ib(1).race##c.educ ib(1).race##c.protestant ib(1).race##c.catholic ib(1).race##c.evangelical ib(1).race##c.rel_attend ib(1).race##c.relig_import ib(1).race##c.parent ib(1).race##c.married ib(1).race##c.union_house ib(1).race##c.unemployed ib(1).race##c.r_hhinc ib(1).race##c.homeowner ib(1).race##c.newsint_recode  ib(1).race##c.south ib(1).race##i.year if pid7_pt<4& state~=12|| state:  || county_fips :  , var cov(id)
outreg2 using Table_2_Part_Sort.xls, ctitle(Dem NO FL) label alpha(0.001, 0.01, 0.05)  dec(6)

**Excluding HI
mixed part_sort_c ib(1).race##c.pct_black  ib(1).race##c.pct_latino ib(1).race##c.pct_asian_pi ib(1).race##c.pct_foreign_born ib(1).race##c.rate_black  ib(1).race##c.rate_latino ib(1).race##c.rate_asian ib(1).race##c.rate_foreign  ib(1).race##c.county_pct_black ib(1).race##c.county_pct_latino  ib(1).race##c.county_pct_asian_pi ib(1).race##c.county_pct_foreignborn ib(1).race##c.county_rate_black ib(1).race##c.county_rate_latino  ib(1).race##c.county_rate_asian ib(1).race##c.county_rate_foreignborn ib(1).race##c.hh_income_overall   ib(1).race##c.state_pop ib(1).race##c.density_pop ib(1).race##c.pct_college ib(1).race##c.unemployment ib(1).race##c.gini_coefficient ib(1).race##c.county_density  ib(1).race##c.county_pct_college ib(1).race##c.county_hh_income_overall ib(1).race##c.county_unemployment ib(1).race##c.county_gini_coefficient   ib(1).race##c.age ib(1).race##c.female ib(1).race##c.educ ib(1).race##c.protestant ib(1).race##c.catholic ib(1).race##c.evangelical ib(1).race##c.rel_attend ib(1).race##c.relig_import ib(1).race##c.parent ib(1).race##c.married ib(1).race##c.union_house ib(1).race##c.unemployed ib(1).race##c.r_hhinc ib(1).race##c.homeowner ib(1).race##c.newsint_recode  ib(1).race##c.south ib(1).race##i.year if pid7_pt<4& state~=15|| state:  || county_fips :  , var cov(id)
outreg2 using Table_2_Part_Sort.xls, ctitle(Dem NO HI) label alpha(0.001, 0.01, 0.05)  dec(6)



**************Table A7 Republican Respondents Full Model of Partisan Ideological Sorting without CA, FL and HI

mixed part_sort_c ib(1).race##c.pct_black  ib(1).race##c.pct_latino ib(1).race##c.pct_asian_pi ib(1).race##c.pct_foreign_born ib(1).race##c.rate_black  ib(1).race##c.rate_latino ib(1).race##c.rate_asian ib(1).race##c.rate_foreign  ib(1).race##c.county_pct_black ib(1).race##c.county_pct_latino  ib(1).race##c.county_pct_asian_pi ib(1).race##c.county_pct_foreignborn ib(1).race##c.county_rate_black ib(1).race##c.county_rate_latino  ib(1).race##c.county_rate_asian ib(1).race##c.county_rate_foreignborn ib(1).race##c.hh_income_overall   ib(1).race##c.state_pop ib(1).race##c.density_pop ib(1).race##c.pct_college ib(1).race##c.unemployment ib(1).race##c.gini_coefficient ib(1).race##c.county_density  ib(1).race##c.county_pct_college ib(1).race##c.county_hh_income_overall ib(1).race##c.county_unemployment ib(1).race##c.county_gini_coefficient   ib(1).race##c.age ib(1).race##c.female ib(1).race##c.educ ib(1).race##c.protestant ib(1).race##c.catholic ib(1).race##c.evangelical ib(1).race##c.rel_attend ib(1).race##c.relig_import ib(1).race##c.parent ib(1).race##c.married ib(1).race##c.union_house ib(1).race##c.unemployed ib(1).race##c.r_hhinc ib(1).race##c.homeowner ib(1).race##c.newsint_recode  ib(1).race##c.south ib(1).race##i.year if pid7_pt>4& state~=6|| state:  || county_fips :  , var cov(id)
outreg2 using Table_2_Part_Sort.xls, ctitle(Rep NO CA) label alpha(0.001, 0.01, 0.05)  dec(6)

**Excluding FL
mixed part_sort_c ib(1).race##c.pct_black  ib(1).race##c.pct_latino ib(1).race##c.pct_asian_pi ib(1).race##c.pct_foreign_born ib(1).race##c.rate_black  ib(1).race##c.rate_latino ib(1).race##c.rate_asian ib(1).race##c.rate_foreign  ib(1).race##c.county_pct_black ib(1).race##c.county_pct_latino  ib(1).race##c.county_pct_asian_pi ib(1).race##c.county_pct_foreignborn ib(1).race##c.county_rate_black ib(1).race##c.county_rate_latino  ib(1).race##c.county_rate_asian ib(1).race##c.county_rate_foreignborn ib(1).race##c.hh_income_overall   ib(1).race##c.state_pop ib(1).race##c.density_pop ib(1).race##c.pct_college ib(1).race##c.unemployment ib(1).race##c.gini_coefficient ib(1).race##c.county_density  ib(1).race##c.county_pct_college ib(1).race##c.county_hh_income_overall ib(1).race##c.county_unemployment ib(1).race##c.county_gini_coefficient   ib(1).race##c.age ib(1).race##c.female ib(1).race##c.educ ib(1).race##c.protestant ib(1).race##c.catholic ib(1).race##c.evangelical ib(1).race##c.rel_attend ib(1).race##c.relig_import ib(1).race##c.parent ib(1).race##c.married ib(1).race##c.union_house ib(1).race##c.unemployed ib(1).race##c.r_hhinc ib(1).race##c.homeowner ib(1).race##c.newsint_recode  ib(1).race##c.south ib(1).race##i.year if pid7_pt>4& state~=12|| state:  || county_fips :  , var cov(id)
outreg2 using Table_2_Part_Sort.xls, ctitle(Rep NO FL) label alpha(0.001, 0.01, 0.05)  dec(6)

**Excluding HI
mixed part_sort_c ib(1).race##c.pct_black  ib(1).race##c.pct_latino ib(1).race##c.pct_asian_pi ib(1).race##c.pct_foreign_born ib(1).race##c.rate_black  ib(1).race##c.rate_latino ib(1).race##c.rate_asian ib(1).race##c.rate_foreign  ib(1).race##c.county_pct_black ib(1).race##c.county_pct_latino  ib(1).race##c.county_pct_asian_pi ib(1).race##c.county_pct_foreignborn ib(1).race##c.county_rate_black ib(1).race##c.county_rate_latino  ib(1).race##c.county_rate_asian ib(1).race##c.county_rate_foreignborn ib(1).race##c.hh_income_overall   ib(1).race##c.state_pop ib(1).race##c.density_pop ib(1).race##c.pct_college ib(1).race##c.unemployment ib(1).race##c.gini_coefficient ib(1).race##c.county_density  ib(1).race##c.county_pct_college ib(1).race##c.county_hh_income_overall ib(1).race##c.county_unemployment ib(1).race##c.county_gini_coefficient   ib(1).race##c.age ib(1).race##c.female ib(1).race##c.educ ib(1).race##c.protestant ib(1).race##c.catholic ib(1).race##c.evangelical ib(1).race##c.rel_attend ib(1).race##c.relig_import ib(1).race##c.parent ib(1).race##c.married ib(1).race##c.union_house ib(1).race##c.unemployed ib(1).race##c.r_hhinc ib(1).race##c.homeowner ib(1).race##c.newsint_recode  ib(1).race##c.south ib(1).race##i.year if pid7_pt>4& state~=15|| state:  || county_fips :  , var cov(id)
outreg2 using Table_2_Part_Sort.xls, ctitle(Rep NO HI) label alpha(0.001, 0.01, 0.05)  dec(6)




**************Summary Statistics by Group  (Tables A2.a-A2.d)

****Based on the larger sample used to estimate the Partisan Sorting Model 
*Tables where then copied to Word for clean presentation

**Create in-sample indicator--predicted values within the sample
mixed part_sort_c ib(1).race##c.pct_black  ib(1).race##c.pct_latino ib(1).race##c.pct_asian_pi ib(1).race##c.pct_foreign_born ib(1).race##c.rate_black  ib(1).race##c.rate_latino ib(1).race##c.rate_asian ib(1).race##c.rate_foreign  ib(1).race##c.county_pct_black ib(1).race##c.county_pct_latino  ib(1).race##c.county_pct_asian_pi ib(1).race##c.county_pct_foreignborn ib(1).race##c.county_rate_black ib(1).race##c.county_rate_latino  ib(1).race##c.county_rate_asian ib(1).race##c.county_rate_foreignborn ib(1).race##c.hh_income_overall   ib(1).race##c.state_pop ib(1).race##c.density_pop ib(1).race##c.pct_college ib(1).race##c.unemployment ib(1).race##c.gini_coefficient ib(1).race##c.county_density  ib(1).race##c.county_pct_college ib(1).race##c.county_hh_income_overall ib(1).race##c.county_unemployment ib(1).race##c.county_gini_coefficient   ib(1).race##c.age ib(1).race##c.female ib(1).race##c.educ ib(1).race##c.protestant ib(1).race##c.catholic ib(1).race##c.evangelical ib(1).race##c.rel_attend ib(1).race##c.relig_import ib(1).race##c.parent ib(1).race##c.married ib(1).race##c.union_house ib(1).race##c.unemployed ib(1).race##c.r_hhinc ib(1).race##c.homeowner ib(1).race##c.newsint_recode  ib(1).race##c.south ib(1).race##i.year|| state:  || county_fips :  , var cov(id)
 predict part_sort_y_hat if e(sample)
 
 **Summary statistics by group for sample of respondents included in the sample of partisan sorting model
 
 **White
sum pid7_pt ideo5_pt part_sort_c part_sort part_sort_a   pct_black   pct_latino  pct_asian_pi  pct_foreign_born  rate_black   rate_latino  rate_asian  rate_foreign   county_pct_black  county_pct_latino   county_pct_asian_pi  county_pct_foreignborn  county_rate_black  county_rate_latino   county_rate_asian  county_rate_foreignborn  hh_income_overall    state_pop  density_pop  pct_college  unemployment  gini_coefficient  county_density   county_pct_college  county_hh_income_overall  county_unemployment  county_gini_coefficient    age  female  educ  protestant  catholic  evangelical  rel_attend  relig_import parent  married  union_house  unemployed  r_hhinc  homeowner  newsint_recode   south year if part_sort_y_hat~=. & race==1

**Black
sum pid7_pt ideo5_pt part_sort_c part_sort part_sort_a   pct_black   pct_latino  pct_asian_pi  pct_foreign_born  rate_black   rate_latino  rate_asian  rate_foreign   county_pct_black  county_pct_latino   county_pct_asian_pi  county_pct_foreignborn  county_rate_black  county_rate_latino   county_rate_asian  county_rate_foreignborn  hh_income_overall    state_pop  density_pop  pct_college  unemployment  gini_coefficient  county_density   county_pct_college  county_hh_income_overall  county_unemployment  county_gini_coefficient    age  female  educ  protestant  catholic  evangelical  rel_attend  relig_import parent  married  union_house  unemployed  r_hhinc  homeowner  newsint_recode   south year if part_sort_y_hat~=. & race==2

**Latino
sum pid7_pt ideo5_pt part_sort_c part_sort part_sort_a   pct_black   pct_latino  pct_asian_pi  pct_foreign_born  rate_black   rate_latino  rate_asian  rate_foreign   county_pct_black  county_pct_latino   county_pct_asian_pi  county_pct_foreignborn  county_rate_black  county_rate_latino   county_rate_asian  county_rate_foreignborn  hh_income_overall    state_pop  density_pop  pct_college  unemployment  gini_coefficient  county_density   county_pct_college  county_hh_income_overall  county_unemployment  county_gini_coefficient    age  female  educ  protestant  catholic  evangelical  rel_attend  relig_import parent  married  union_house  unemployed  r_hhinc  homeowner  newsint_recode   south year if part_sort_y_hat~=. & race==3

**Asian/PI
sum pid7_pt ideo5_pt part_sort_c part_sort part_sort_a  pct_black   pct_latino  pct_asian_pi  pct_foreign_born  rate_black   rate_latino  rate_asian  rate_foreign   county_pct_black  county_pct_latino   county_pct_asian_pi  county_pct_foreignborn  county_rate_black  county_rate_latino   county_rate_asian  county_rate_foreignborn  hh_income_overall    state_pop  density_pop  pct_college  unemployment  gini_coefficient  county_density   county_pct_college  county_hh_income_overall  county_unemployment  county_gini_coefficient    age  female  educ  protestant  catholic  evangelical  rel_attend  relig_import parent  married  union_house  unemployed  r_hhinc  homeowner  newsint_recode   south year if part_sort_y_hat~=. & race==4


